﻿<link href="~/miniui_net/demo/demo.css" rel="stylesheet" />
<style>
    body, html {
        margin: 0;
        padding: 0;
        width: 100%;
        height: 100%;
    }
</style>
<div>
    <div id="treegrid1" class="mini-treegrid" style="width: 100%; height: 100%;"
         url="/Home/GetUserMenuList?ROLEID=0" showTreeIcon="true"
         treeColumn="MENUNAME" idField="MENUID" parentField="PID" resultAsTree="false"
         allowResize="false" expandOnLoad="true">
        <div property="columns">
            <div type="indexcolumn" headerAlign="center">序号</div>
            <div name="MENUNAME" field="MENUNAME" align="center" headerAlign="center">菜单名称</div>
            <div field="CONTROLLER" align="center" headerAlign="center">控制器</div>
            <div field="METHODS" align="center" headerAlign="center">方法</div>
            <div field="MENUTYPE" align="center" headerAlign="center">类型</div>
            <div field="ISENABLE" align="center" headerAlign="center" renderer="onIsendRenderer">启用</div>
            <div field="CREATEDATE" dateFormat="yyyy-MM-dd" align="center" headerAlign="center">开始日期</div>
            <div field="UPDATEDATE" dateFormat="yyyy-MM-dd" align="center" headerAlign="center">完成日期</div>
            <div name="action" width="150" headerAlign="center" align="center" renderer="onActionRenderer">操作</div>
        </div>
    </div>
</div>
<script src="~/miniui_net/scripts/boot.js"></script>
<script>
    mini.parse();
    var grid = mini.get("treegrid1");
    grid.load();

    // 操作按钮
    function onActionRenderer(e) { 
        var rowIndex = e.row;
        if (rowIndex.PID == -1) {
            return '<a class="mini-button" style="width:60px;" onclick="Add()">新增</a> ' +
            '<a class="mini-button" style="width:60px;" onclick="update()">修改</a> '
        }
        var s = '<a class="mini-button" style="width:60px;" onclick="Add()">新增</a> ' +
            '<a class="mini-button" style="width:60px;" onclick="update()">修改</a> '+
           '<a class="mini-button" style="width:60px;" onclick="delete()">删除</a> ';
        return s;
    }
    function onIsendRenderer(e) {
        if (e.value == 1) return "启用";
        else return "禁用";  
    }
    function Add() {
        console.log(11);
    }
</script>